package ru.ifmo.thesis.domain;

import ru.ifmo.thesis.quantities.Kilometers;

public abstract class AbstractGeoService {
	
	protected Location officeLocation;

	public abstract Kilometers<Double> distance(Location first, Location second);
	
	public abstract Location getLocation(String address, double latitude, double longtitude);

	protected AbstractGeoService() {
	}
	
	protected void setOfficeLocation(Location officeLocation) {
		this.officeLocation = officeLocation;
	}
	
	protected Kilometers<Double> distanceInternal(Location first, Location second) {
		double deltaLat = first.getLatitude() - second.getLatitude();
		double deltaLong = first.getLongtitude() - second.getLongtitude();
		double result = Math.sqrt((deltaLat * deltaLat) + (deltaLong * deltaLong));
	
		return new Kilometers<Double>(result);
	}

	public Location getOfficeLocation() {
		return officeLocation;
	}
}